package com.example.evanproject.controller;

import com.example.evanproject.service.InvolvedService;
import com.example.evanproject.service.impl.InvolvedServiceImpl;
import com.example.evanproject.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@CrossOrigin
public class InvolvedController {

    @Autowired
    private InvolvedServiceImpl involvedService;


    /*返回某个用户的关注的与粉丝的人数以及具体信息(头像以及姓名)*/
    @RequestMapping("selectbyid")
    public AjaxResult selectbyidinfo(Integer userid){

        return AjaxResult.success(involvedService.selectbyidinfo(userid));
    }

//    添加关注以及取消关注(flag==1表示添加id,flag==2表示取消关注)
    @RequestMapping("trunstate")
    public AjaxResult trunstateinfo(Integer myId,Integer userId,Integer flag){
        if(myId==userId){
            return AjaxResult.error("禁止本人关注取消关注");
        }
        return AjaxResult.success(involvedService.trunstateinfo(myId,userId,flag));
    }

//    两者之前的关系
@RequestMapping("relationship")
public AjaxResult relationship(Integer followersId,Integer befollowedId){

    return AjaxResult.success(involvedService.relationship(followersId,befollowedId));
}


//查看关注的人数以及粉丝
@RequestMapping("relationListNum")
public AjaxResult relationListNum(Integer peopleId){
    return AjaxResult.success(involvedService.relationListNum(peopleId));
}

}
